#include <func.h>

int main(void)
{
    int sock_fd = socket(AF_INET, SOCK_STREAM, 0);
    
    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(atoi("8080"));
    addr.sin_addr.s_addr = inet_addr("127.0.0.1");

    if(connect(sock_fd, (struct sockaddr*)&addr, sizeof(addr)) == -1)
    {
        printf("未找到服务器\n");
        error(1, errno, "connect");
    }
    send(sock_fd, "hehe", 4, 0);

    printf("已连接服务器\n");
    char buf[50] = {0};
    recv(sock_fd, buf, sizeof(buf), 0);
    printf("buf: %s\n", buf);

    close(sock_fd);
    return 0;
}